/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#include "ChaseCamera.h"

namespace PQGame
{
	ChaseCamera::ChaseCamera(Ogre::SceneNode *baseNode,
			Ogre::Camera *cam,
			Ogre::Vector3 offset)
	{
		camera=cam;
		pivotNode=baseNode->createChildSceneNode(baseNode->getName()+"_PivotNode");
		camNode=pivotNode->createChildSceneNode(baseNode->getName()+"_CameraNode",offset);

		//Ogre::Vector3 pos=baseNode->getPosition();
		//camera->lookAt(pos.x,pos.y,pos.z);
		
		camNode->pitch(Ogre::Degree(30));
		camNode->yaw(Ogre::Degree(180));


		camNode->attachObject(camera);
	}

	ChaseCamera::~ChaseCamera(void)
	{
	}

	Ogre::Camera *ChaseCamera::getCamera()
	{
		return camera;
	}

	void ChaseCamera::spin(const Ogre::Radian &angle)
	{
		pivotNode->yaw(angle);
	}

	void ChaseCamera::pitch(const Ogre::Radian &angle)
	{
		camNode->pitch(angle);
	}

}
